<template >
	<div style="width: 100%;height: 950px;position: relative;background-color:rgba(24,80,55,0.1);">
		<div style="position: absolute;left: 40%;top: 23%;width:400px;text-align: center;font-size: 20px;font-weight:bolder;color: #666666">碳银网管理系统</div>
		<div id="app" style="position: absolute;left: 40%;top: 27%;height:200px;width:400px;background-color:#bdbfbf;padding-top: 100px;box-shadow: 10px 10px 5px #a7a9aa;">
			<el-form ref="form" :model="form" label-width="80px" >
				<el-form-item label="用户名">
					<el-input v-model="form.loginName" style="width:260px"></el-input>
				</el-form-item>
				<el-form-item label="密码">
					<el-input v-model="form.password" type="password" style="width:260px"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" @click="onLogin" :loading="load">登录</el-button>
				</el-form-item>
			</el-form>
			<span style="text-align: center;display: inline-block;margin:0 auto;width:400px;color: #666666">2017 © Tanwin</span>
		</div>
	</div>
</template>
<script>
import _http from './components/common/http.vue'
	export default{

		data(){
			return{
				load:false,
				apiPort:{
//           		登录接口
					loginApi:'system/login'
				},
				form:{
					loginName:'',
					password:'',
				}
			}
		},
		methods:{
			onLogin(){
				console.log()
				this.load=true
				var that = this
				var params = that.querystring.stringify(this.form)
				var limitList={}
				_http.axiosRequest(this,this.apiPort.loginApi,params,(res)=>{
					console.log(this.form)
					console.log(res)
//					对权限进行控制
	            	if (res.data.code === 200) {
						console.log(res.data.authority)
						for(var j=1;j<=200;j++){
						var b =_http.getLimit(res.data.authority,j)
							limitList["limitId"+j]=b
							console.log(j)
							console.log( limitList["limitId"+j])
						}
						localStorage.setItem("limitList",JSON.stringify(limitList))
						console.log('对权限进行存取')
						console.log(limitList.limitId100.status)
						sessionStorage.setItem('login',true)
						localStorage.setItem('userId',res.data.userid)
						localStorage.setItem('userName',res.data.loginName)
						console.log(res.data.userid)
						window.location.href="/working/inform/#/cust/company/companyList"
					}
					else{
						this.$message.error(res.data.msg);
						setTimeout(function(){
							that.load=false
						},1000)
					}
	            })
			}
		}
	}
</script>